using System;

namespace NET.Library.Windows.Forms
{
	/// <summary>
	/// Summary description for Values.
	/// </summary>
	public class Values : NET.Library.Manipulation.Strings
	{
		/// '-----------------------------------------------------------------------------------------
		/// 'Returns integer value from TextBox value in a windows form
		/// '-----------------------------------------------------------------------------------------
		public static int intTextVal(System.Windows.Forms.TextBox TextBox)
		{
			return (!IsEmptyString(TextBox.Text)) ? Convert.ToInt32(RemoveInvalidChar(TextBox.Text)): int.MinValue;
		}

		/// '-----------------------------------------------------------------------------------------
		/// 'Returns string value from TextBox value in a windows form
		/// '-----------------------------------------------------------------------------------------
		public static string strTextVal(System.Windows.Forms.TextBox TextBox)
		{
            return (!IsEmptyString(TextBox.Text)) ? RemoveInvalidChar(TextBox.Text) : String.Empty;
		}
        /// '-----------------------------------------------------------------------------------------
        /// <summary>
        /// Convert TextBox text in a windows form to a Single value
        /// </summary>
        /// <param name="TextBox"></param>
        /// <returns>Single</returns>
        /// '-----------------------------------------------------------------------------------------
        public static Single sngTextVal(System.Windows.Forms.TextBox TextBox)
        {
            return (!IsEmptyString(TextBox.Text)) ? Convert.ToSingle(RemoveInvalidChar(TextBox.Text)) : Single.MinValue;
        }
		/// '-----------------------------------------------------------------------------------------
		/// 'Returns integer value from Label value in a windows form
		/// '-----------------------------------------------------------------------------------------
		public static int intTextVal(System.Windows.Forms.Label Label)
		{
            return (!IsEmptyString(Label.Text)) ? Convert.ToInt32(RemoveInvalidChar(Label.Text)) : int.MinValue;
		}

		/// '-----------------------------------------------------------------------------------------
		/// 'Returns string value from Label value in a windows form
		/// '-----------------------------------------------------------------------------------------
		public static string strTextVal(System.Windows.Forms.Label Label)
		{
            return (!IsEmptyString(Label.Text)) ? RemoveInvalidChar(Label.Text) : String.Empty;
		}
        /// '-----------------------------------------------------------------------------------------
        /// <summary>
        /// Convert Label text in a windows form to a Single value
        /// </summary>
        /// <param name="Label"></param>
        /// <returns>Single</returns>
        /// '-----------------------------------------------------------------------------------------
        public static Single sngTextVal(System.Windows.Forms.Label Label)
        {
            return (!IsEmptyString(Label.Text)) ? Convert.ToSingle(RemoveInvalidChar(Label.Text)) : Single.MinValue;
        }
		/// '-----------------------------------------------------------------------------------------
		/// 'Returns integer value for checkbox fields in a windows form
		/// '-----------------------------------------------------------------------------------------
		public static int intChkboxVal(System.Windows.Forms.CheckBox CheckBox)
		{
			return CheckBox.Checked == true ? 1 : 2;
		}


		// '-----------------------------------------------------------------------------------------
		// 'Returns integer value for checkboxlist fields
		// '-----------------------------------------------------------------------------------------
		//		public static int intChkboxlsVal(CheckBoxList CheckBoxList, int Item)
		//		{
		////			foreach (int i in CheckBoxList.Items)
		////			{
		////				if CheckBoxList.Items(i).s
		////			}
		//
		//			if (CheckBoxList.Items.Count .Contains( Items.Item(Item).Selected = true))
		//			{
		//				return 1;
		//			}
		//			else
		//			{
		//				return 2;
		//			}
		//		}


		//		/// '-----------------------------------------------------------------------------------------
		//		/// 'Returns string value from radiobuttonlist selected value in a windows form
		//		/// '-----------------------------------------------------------------------------------------
		//		public static string strRadioListVal(System.Windows.Forms.GroupBox GroupBox)
		//		{
		//			foreach(int i in GroupBox.Controls)
		//			{
		//				if(GroupBox.Controls[i].GetType() == System.Windows.Forms.RadioButton)
		//				{
		//					RadioButton radBtn = GroupBox.Controls[i];
		//					if(radBtn.
		//				}
		//			}
		//			return RadioButtonList.SelectedItem!=null ? RemoveInvalidChar(RadioButton.SelectedItem.Value) : String.Empty;
		//		}


		//		/// '-----------------------------------------------------------------------------------------
		//		/// 'Returns string value from ComboBox selected index in a windows form
		//		/// '-----------------------------------------------------------------------------------------
		//		public static string strDropDownListValue(System.Windows.Forms.ComboBox ComboBox) 
		//		{
		//			return ComboBox.SelectedItem.ToString().Trim().Length > 0 ? ComboBox.SelectedIndex.ToString() : String.Empty;
		//		}

		/// '-----------------------------------------------------------------------------------------
		/// 'Returns string value from ComboBox selected text in a windows form
		/// '-----------------------------------------------------------------------------------------
		public static string strDropDownListText(System.Windows.Forms.ComboBox ComboBox)
		{
			return ComboBox.SelectedItem!=null ? RemoveInvalidChar(ComboBox.SelectedItem.ToString()) : String.Empty;
		}

        /// '-----------------------------------------------------------------------------------------
        /// 'Returns integer value from ComboBox selected value in a windows form
        /// '-----------------------------------------------------------------------------------------
        public static int intDropDownListVal(System.Windows.Forms.ComboBox ComboBox)
        {
            return ComboBox.SelectedItem != null ? Convert.ToInt32(ComboBox.SelectedValue) : 0;
        }
	}
}
